package org.platform.hrv.lib.hrv.calc.parameter.v2;

import org.platform.hrv.lib.hrv.RRData;
import org.platform.hrv.lib.hrv.calc.parameter.HRVDataProcessor;
import org.platform.hrv.lib.hrv.calc.parameter.HRVParameter;
import org.platform.hrv.lib.hrv.calc.parameter.HRVParameterEnum;

import java.util.Arrays;

/**
 * MeanNNIProcessor
 *
 * @program: ecg-zoo
 * @description: mean NNI
 * @author: Mr.Nanke
 **/
public class MeanNNIProcessor implements HRVDataProcessor {
    @Override
    public HRVParameter process(RRData data) {
        double m = Arrays.stream(data.getValueAxis()).average().orElse(0.0);
        return new HRVParameter(HRVParameterEnum.MEANNNI, m, data.getValueAxisUnit().toString());
    }

    @Override
    public boolean validData(RRData data) {
        return data.getValueAxis().length > 0;
    }

}